import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/net/response/service_order_ddetail_data.dart';
import 'package:ls_work/res/colors.dart';
import 'package:ls_work/viewmodel/new_yyt_view_model.dart';
import 'package:ls_work/viewmodel/service_order/receive_service_order_view_model.dart';
import 'package:ls_work/viewmodel/service_order/service_order_detail_view_model.dart';
import 'package:ls_work/viewmodel/service_order/service_order_home_view_model.dart';

class ReceiveServiceOrderWidget extends BaseStatefulMvvmWidget {
  ServiceOrderDdetailData detailData;

  ReceiveServiceOrderWidget(this.detailData);

  @override
  State<StatefulWidget> createState() => _ReceiveServiceOrderState();
}

class _ReceiveServiceOrderState extends BaseMvvmState<
    ReceiveServiceOrderViewModel, ReceiveServiceOrderWidget> {
  @override
  Widget buildLoadingContentView() {
    return Column(
      children: [
        Row(
          children: [
            CommonText('服务部门').setWeight(1),
            CommonText(NewYytViewModel.userInfo?.officeName??"", textColor: Colours.order_text_grey).setWeight(3)
          ],
        ).addToContainer(
            decoration: BoxDecoration(
                color: Colors.white,
                border: Border(
                    bottom: BorderSide(color: Colors.grey[300]!, width: 0.5))),
            padding: EdgeInsets.symmetric(horizontal: 16, vertical: 14)),
        Row(
          children: [
            CommonText('服务人员').setWeight(1),
            CommonText(NewYytViewModel.userInfo?.name??"", textColor: Colours.order_text_grey).setWeight(3)
          ],
        ).addToContainer(
            decoration: BoxDecoration(
                color: Colors.white,
                border: Border(
                    bottom: BorderSide(color: Colors.grey[300]!, width: 0.5))),
            padding: EdgeInsets.symmetric(horizontal: 16, vertical: 14)),
        Row(
          children: [
            CommonText('服务电话').setWeight(1),
            CommonText(NewYytViewModel.userInfo?.mobile??"", textColor: Colours.order_text_grey)
                .setWeight(3)
          ],
        ).addToContainer(
            decoration: BoxDecoration(
                color: Colors.white,
                border: Border(
                    bottom: BorderSide(color: Colors.grey[300]!, width: 0.5))),
            padding: EdgeInsets.symmetric(horizontal: 16, vertical: 14)),
        Row(
          children: [
            ElevatedButton(
              onPressed: () {
                viewModel.refuseOrderClick();
              },
              child: CommonText('拒单'),
              style: ButtonStyle(
                  minimumSize: WidgetStateProperty.all(Size.fromHeight(40)),
                  shape: WidgetStateProperty.all(StadiumBorder(
                      side: BorderSide(color: Color(0xffD4D5DA)))),
                  elevation: WidgetStateProperty.all(0),
                  overlayColor: WidgetStateProperty.all(Colors.grey[100]),
                  backgroundColor: WidgetStateProperty.all(Colors.white)),
            ).setWeight(1),
            Container(
              width: 8,
            ),
            ElevatedButton(
              onPressed: () {
                viewModel.receiveOrderClick();
              },
              child: CommonText('接单', textColor: Colors.white),
              style: ButtonStyle(
                minimumSize: WidgetStateProperty.all(Size.fromHeight(40)),
                shape: WidgetStateProperty.all(
                    StadiumBorder(side: BorderSide(color: Color(0xffD4D5DA)))),
                elevation: WidgetStateProperty.all(0),
              ),
            ).setWeight(1)
          ],
        ).addToContainer(
            color: Colors.white,
            margin: EdgeInsets.symmetric(vertical: 16),
            padding: EdgeInsets.symmetric(horizontal: 16,vertical: 8))
      ],
    );
  }

  @override
  Widget buildRootView(BuildContext context, Widget loadingContentWidget) {
    return loadingContentWidget;
  }

  @override
  ReceiveServiceOrderViewModel createViewModel() {
    return ReceiveServiceOrderViewModel(context,widget.detailData);
  }

  @override
  void onRetryClick() {

  }
}
